﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using CMISLibrary;
using BCNPCObject.THONGTIN_KHANG;
using BCNPCObject.DB;
using System.Data.OracleClient;
using System.Windows;
using System.Windows.Forms;
using BCNPCObject;

namespace bus_TienichNPC
{
    public class cls_THONGTIN_KHANG
    {
        OracleConnection connorcl = new OracleConnection("Data Source=(  DESCRIPTION ="
                                                          + "(ADDRESS = (PROTOCOL = TCP)(HOST = 10.21.0.99)(PORT = 1521))"
                                                          + "(CONNECT_DATA ="
                                                          + "(SERVER = DEDICATED)"
                                                          + "(SERVICE_NAME = CMISPC1)"
                                                          + "));Persist Security Info=True;User ID=cmis01;Password=cmis01");
        string strsql = ""; 

        public void dkvads(string strSql)
        {
            connorcl.Open();           
            OracleCommand cmd = new OracleCommand(strSql, connorcl);
            
            cmd.ExecuteNonQuery();
            connorcl.Close();
        }

        public bool update_NPC_SUBS_SMS_sql(string strMakhang, string strDTHOAI, ref string strErr)
        {
            try
            {
                strsql = "UPDATE NPC_SUBS_SMS SET SO_DTHOAI = '" + strDTHOAI + "'"
                        + "WHERE MA_KHANG = '" + strMakhang + "'";
                dkvads(strsql);
                return true;
            }
            catch (Exception ex)
            {
                strErr = ex.ToString();
                return false;
            }
        }

        public bool Insert_NPC_SUBS_SMS_sql(string strMadviqly, string strMakhang, string strDTHOAI, ref string strErr)
        {
            try
            {
                strsql = "INSERT INTO cmis01.NPC_SUBS_SMS ( ID, MA_DVIQLY,  MA_KHANG ,  SO_DTHOAI,  COMMANDCODE,  SERVICEID  ,  AUTOTIME  )"
                         + " VALUES (cmis01.S_NPC_SUBS_SMS.NEXTVAL,'" + strMadviqly + "','" + strMakhang + "','" + strDTHOAI + "','PA','6000',SYSDATE)";
                dkvads(strsql);
                strErr = "";
                return true;
            }
            catch (Exception ex)
            {
                strErr = ex.ToString();
                return false;
            }
        }


        public bool update_HDG_KHACH_HANG_sql(string strMakhang, string strDTHOAI, DateTime dtimeNgayHluc, int intTrangthai, ref string strErr)
        {
            try
            {
                strsql = "UPDATE HDG_KHACH_HANG SET DTHOAI = '" + strDTHOAI + "'"
                        + "WHERE MA_KHANG = '" + strMakhang + "'" + "AND NGAY_HLUC = TO_DATE('" + dtimeNgayHluc.ToString("MM/dd/yyyy") + "','MM/dd/yyyy') AND TRANG_THAI = " + intTrangthai;
                dkvads(strsql);
                strErr = "";
                return true;
            }
            catch (Exception ex)
            {
                strErr = ex.ToString();
                return false;
            }
        }
        
        public bool ktraKhangExistsSMS(string strMakhang)
        {
            string strSql = "";
            strSql = "select * from cmis01.NPC_SUBS_SMS where MA_KHANG='" + strMakhang + "'";
            connorcl.Open();
            //OracleDataReader Reader = new OracleDataReader();
            bool Ton_tai = false;
            OracleCommand cmd = new OracleCommand(strSql, connorcl);
            OracleDataReader Reader = cmd.ExecuteReader();
            if (Reader.Read() == true)
            {
                Ton_tai = true;
            }
            else
            { Ton_tai = false; }
            connorcl.Close();

            return Ton_tai;
        }

        public bool delete_NPC_SUBS_SMS_sql(string strMadviqly, string strMakhang, ref string strErr)
        {
            try
            {
                strsql = " DELETE FROM CMIS01.NPC_SUBS_SMS "
                           + " WHERE ma_khang='" + strMakhang + "'";
                dkvads(strsql);
                strErr = "";
                return true;
            }
            catch (Exception ex)
            {
                strErr = ex.ToString();
                return false;
            }
        }

        #region   Atributes        
        private cls_HDG_KHACH_HANG_Controller obj_HDG_KHACH_HANG_Controller;
        private cls_HDG_DIEM_DO_Controller obj_HDG_DIEM_DO_Controller;        
        private cls_HDG_VITRI_DDO_Controller obj_HDG_VITRI_DDO_Controller;
        private cls_THONGTIN_KHANG_Controller obj_THONGTIN_KHANG_Controller;
        # endregion

        #region   Constructor

        public cls_THONGTIN_KHANG()
        {            
            obj_HDG_KHACH_HANG_Controller = new cls_HDG_KHACH_HANG_Controller();
            obj_HDG_DIEM_DO_Controller = new cls_HDG_DIEM_DO_Controller();            
            obj_HDG_VITRI_DDO_Controller = new cls_HDG_VITRI_DDO_Controller();
            obj_THONGTIN_KHANG_Controller = new cls_THONGTIN_KHANG_Controller();
        }

        #endregion

        #region MapInfo

        public void mapEntityToInfoHDG_KHACH_HANG(DataSet Entity)
        {
            
            this.obj_HDG_KHACH_HANG_Controller = new cls_HDG_KHACH_HANG_Controller();
            
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["ID_HDONG"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.ID_HDONG = Convert.ToInt64(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["ID_HDONG"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["MA_DVIQLY"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.MA_DVIQLY = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["MA_DVIQLY"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["MA_KHANG"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.MA_KHANG = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["MA_KHANG"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["SO_NHA"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.SO_NHA = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["SO_NHA"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["DUONG_PHO"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.DUONG_PHO = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["DUONG_PHO"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["DCHI_HDON"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.DCHI_HDON = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["DCHI_HDON"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["MASO_THUE"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.MASO_THUE = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["MASO_THUE"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["TLE_THUE"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.TLE_THUE = Convert.ToDecimal(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["TLE_THUE"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["LOAI_KHANG"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.LOAI_KHANG = Convert.ToInt16(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["LOAI_KHANG"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["MANHOM_KHANG"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.MANHOM_KHANG = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["MANHOM_KHANG"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["MA_NN"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.MA_NN = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["MA_NN"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["TEN_KHANG"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.TEN_KHANG = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["TEN_KHANG"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["TENHDON_KHANG"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.TENHDON_KHANG = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["TENHDON_KHANG"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["TENTAT_KHANG"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.TENTAT_KHANG = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["TENTAT_KHANG"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["NGAY_SINH"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.NGAY_SINH = Convert.ToDateTime(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["NGAY_SINH"].ToString());
            }
            else
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.NGAY_SINH = null;
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["NGAY_HLUC"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.NGAY_HLUC = Convert.ToDateTime(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["NGAY_HLUC"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["TRANG_THAI"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.TRANG_THAI = Convert.ToInt16(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["TRANG_THAI"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["THANG"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.THANG = Convert.ToInt16(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["THANG"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["NAM"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.NAM = Convert.ToInt16(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["NAM"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["MA_DVIDCHINH"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.MA_DVIDCHINH = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["MA_DVIDCHINH"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["TKHOAN_KHANG"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.TKHOAN_KHANG = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["TKHOAN_KHANG"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["MA_NHANG"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.MA_NHANG = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["MA_NHANG"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["MA_KHTT"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.MA_KHTT = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["MA_KHTT"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["MA_LOAIDN"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.MA_LOAIDN = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["MA_LOAIDN"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["DTHOAI"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.DTHOAI = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["DTHOAI"].ToString());
            }
            
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["FAX"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.FAX = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["FAX"].ToString());
            }
            else
            {
 
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["EMAIL"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.EMAIL = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["EMAIL"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["WEBSITE"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.WEBSITE = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["WEBSITE"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["GIOI_TINH"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.GIOI_TINH = Convert.ToInt16(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["GIOI_TINH"].ToString());
            }
            //if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["HTHUC_NHAN_HDON"].ToString().Trim() != string.Empty)
            //{
            //    this.obj_HDG_KHACH_HANG_Controller.pInfor.HTHUC_NHAN_HDON = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["HTHUC_NHAN_HDON"].ToString());
            //}
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["MA_CNANG"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.MA_CNANG = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["MA_CNANG"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["NGAY_TAO"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.NGAY_TAO = Convert.ToDateTime(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["NGAY_TAO"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["NGUOI_TAO"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.NGUOI_TAO = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["NGUOI_TAO"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["NGAY_SUA"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.NGAY_SUA = Convert.ToDateTime(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["NGAY_SUA"].ToString());
            }
            if (Entity.Tables["HDG_KHACH_HANG"].Rows[0]["NGUOI_SUA"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_KHACH_HANG_Controller.pInfor.NGUOI_SUA = Convert.ToString(Entity.Tables["HDG_KHACH_HANG"].Rows[0]["NGUOI_SUA"].ToString());
            }
        }
        public void mapEntityToInfoHDG_DIEM_DO(DataSet Entity)
        {
            if (this.obj_HDG_DIEM_DO_Controller == null)
            {
                this.obj_HDG_DIEM_DO_Controller = new cls_HDG_DIEM_DO_Controller();
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["MA_DVIQLY"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.MA_DVIQLY = Convert.ToString(Entity.Tables["HDG_DIEM_DO"].Rows[0]["MA_DVIQLY"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["MA_DDO"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.MA_DDO = Convert.ToString(Entity.Tables["HDG_DIEM_DO"].Rows[0]["MA_DDO"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["ID_HDONG"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.ID_HDONG = Convert.ToInt64(Entity.Tables["HDG_DIEM_DO"].Rows[0]["ID_HDONG"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["MA_KHANG"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.MA_KHANG = Convert.ToString(Entity.Tables["HDG_DIEM_DO"].Rows[0]["MA_KHANG"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["MA_DDO_DDIEN"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.MA_DDO_DDIEN = Convert.ToString(Entity.Tables["HDG_DIEM_DO"].Rows[0]["MA_DDO_DDIEN"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["MA_CAPDA"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.MA_CAPDA = Convert.ToString(Entity.Tables["HDG_DIEM_DO"].Rows[0]["MA_CAPDA"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["DIA_CHI"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.DIA_CHI = Convert.ToString(Entity.Tables["HDG_DIEM_DO"].Rows[0]["DIA_CHI"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["ID_DIA_CHINH"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.ID_DIA_CHINH = Convert.ToString(Entity.Tables["HDG_DIEM_DO"].Rows[0]["ID_DIA_CHINH"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["KIMUA_CSPK"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.KIMUA_CSPK = Convert.ToInt16(Entity.Tables["HDG_DIEM_DO"].Rows[0]["KIMUA_CSPK"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["CSUAT"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.CSUAT = Convert.ToDecimal(Entity.Tables["HDG_DIEM_DO"].Rows[0]["CSUAT"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["MUC_DICH"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.MUC_DICH = Convert.ToString(Entity.Tables["HDG_DIEM_DO"].Rows[0]["MUC_DICH"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["SO_PHA"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.SO_PHA = Convert.ToInt16(Entity.Tables["HDG_DIEM_DO"].Rows[0]["SO_PHA"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["SOHUU_LUOI"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.SOHUU_LUOI = Convert.ToInt16(Entity.Tables["HDG_DIEM_DO"].Rows[0]["SOHUU_LUOI"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["LOAI_DDO"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.LOAI_DDO = Convert.ToInt16(Entity.Tables["HDG_DIEM_DO"].Rows[0]["LOAI_DDO"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["SO_HO"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.SO_HO = Convert.ToDecimal(Entity.Tables["HDG_DIEM_DO"].Rows[0]["SO_HO"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["LAN_CAPNHAT"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.LAN_CAPNHAT = Convert.ToInt16(Entity.Tables["HDG_DIEM_DO"].Rows[0]["LAN_CAPNHAT"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["THAO_TACDL"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.THAO_TACDL = Convert.ToString(Entity.Tables["HDG_DIEM_DO"].Rows[0]["THAO_TACDL"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["NGAY_HLUC"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.NGAY_HLUC = Convert.ToDateTime(Entity.Tables["HDG_DIEM_DO"].Rows[0]["NGAY_HLUC"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["MO_TA"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.MO_TA = Convert.ToString(Entity.Tables["HDG_DIEM_DO"].Rows[0]["MO_TA"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["TRANG_THAI"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.TRANG_THAI = Convert.ToInt16(Entity.Tables["HDG_DIEM_DO"].Rows[0]["TRANG_THAI"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["TTRANG_TREOTHAO"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.TTRANG_TREOTHAO = Convert.ToInt16(Entity.Tables["HDG_DIEM_DO"].Rows[0]["TTRANG_TREOTHAO"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["MA_CNANG"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.MA_CNANG = Convert.ToString(Entity.Tables["HDG_DIEM_DO"].Rows[0]["MA_CNANG"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["NGAY_TAO"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.NGAY_TAO = Convert.ToDateTime(Entity.Tables["HDG_DIEM_DO"].Rows[0]["NGAY_TAO"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["NGUOI_TAO"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.NGUOI_TAO = Convert.ToString(Entity.Tables["HDG_DIEM_DO"].Rows[0]["NGUOI_TAO"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["NGAY_SUA"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.NGAY_SUA = Convert.ToDateTime(Entity.Tables["HDG_DIEM_DO"].Rows[0]["NGAY_SUA"].ToString());
            }
            if (Entity.Tables["HDG_DIEM_DO"].Rows[0]["NGUOI_SUA"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_DIEM_DO_Controller.pInfor.NGUOI_SUA = Convert.ToString(Entity.Tables["HDG_DIEM_DO"].Rows[0]["NGUOI_SUA"].ToString());
            }
        }
        public void mapEntityToInfoHDG_VITRI_DDO(DataSet Entity)
        {
            if (this.obj_HDG_VITRI_DDO_Controller == null)
            {
                this.obj_HDG_VITRI_DDO_Controller = new cls_HDG_VITRI_DDO_Controller();
            }
            if (Entity.Tables["HDG_VITRI_DDO"].Rows[0]["MA_DVIQLY"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_VITRI_DDO_Controller.pInfor.MA_DVIQLY = Convert.ToString(Entity.Tables["HDG_VITRI_DDO"].Rows[0]["MA_DVIQLY"].ToString());
            }
            if (Entity.Tables["HDG_VITRI_DDO"].Rows[0]["MA_DDO"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_VITRI_DDO_Controller.pInfor.MA_DDO = Convert.ToString(Entity.Tables["HDG_VITRI_DDO"].Rows[0]["MA_DDO"].ToString());
            }
            if (Entity.Tables["HDG_VITRI_DDO"].Rows[0]["ID_VITRI_DDO"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_VITRI_DDO_Controller.pInfor.ID_VITRI_DDO = Convert.ToInt64(Entity.Tables["HDG_VITRI_DDO"].Rows[0]["ID_VITRI_DDO"].ToString());
            }
            if (Entity.Tables["HDG_VITRI_DDO"].Rows[0]["MA_TRAM"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_VITRI_DDO_Controller.pInfor.MA_TRAM = Convert.ToString(Entity.Tables["HDG_VITRI_DDO"].Rows[0]["MA_TRAM"].ToString());
            }
            if (Entity.Tables["HDG_VITRI_DDO"].Rows[0]["MA_LO"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_VITRI_DDO_Controller.pInfor.MA_LO = Convert.ToString(Entity.Tables["HDG_VITRI_DDO"].Rows[0]["MA_LO"].ToString());
            }
            if (Entity.Tables["HDG_VITRI_DDO"].Rows[0]["MA_TO"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_VITRI_DDO_Controller.pInfor.MA_TO = Convert.ToString(Entity.Tables["HDG_VITRI_DDO"].Rows[0]["MA_TO"].ToString());
            }
            if (Entity.Tables["HDG_VITRI_DDO"].Rows[0]["PHA"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_VITRI_DDO_Controller.pInfor.PHA = Convert.ToString(Entity.Tables["HDG_VITRI_DDO"].Rows[0]["PHA"].ToString());
            }
            if (Entity.Tables["HDG_VITRI_DDO"].Rows[0]["SO_COT"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_VITRI_DDO_Controller.pInfor.SO_COT = Convert.ToString(Entity.Tables["HDG_VITRI_DDO"].Rows[0]["SO_COT"].ToString());
            }
            if (Entity.Tables["HDG_VITRI_DDO"].Rows[0]["SO_HOM"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_VITRI_DDO_Controller.pInfor.SO_HOM = Convert.ToString(Entity.Tables["HDG_VITRI_DDO"].Rows[0]["SO_HOM"].ToString());
            }
            if (Entity.Tables["HDG_VITRI_DDO"].Rows[0]["MA_CNANG"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_VITRI_DDO_Controller.pInfor.MA_CNANG = Convert.ToString(Entity.Tables["HDG_VITRI_DDO"].Rows[0]["MA_CNANG"].ToString());
            }
            if (Entity.Tables["HDG_VITRI_DDO"].Rows[0]["NGAY_HLUC"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_VITRI_DDO_Controller.pInfor.NGAY_HLUC = Convert.ToDateTime(Entity.Tables["HDG_VITRI_DDO"].Rows[0]["NGAY_HLUC"].ToString());
            }
            if (Entity.Tables["HDG_VITRI_DDO"].Rows[0]["NGAY_TAO"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_VITRI_DDO_Controller.pInfor.NGAY_TAO = Convert.ToDateTime(Entity.Tables["HDG_VITRI_DDO"].Rows[0]["NGAY_TAO"].ToString());
            }
            if (Entity.Tables["HDG_VITRI_DDO"].Rows[0]["NGUOI_TAO"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_VITRI_DDO_Controller.pInfor.NGUOI_TAO = Convert.ToString(Entity.Tables["HDG_VITRI_DDO"].Rows[0]["NGUOI_TAO"].ToString());
            }
            if (Entity.Tables["HDG_VITRI_DDO"].Rows[0]["NGAY_SUA"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_VITRI_DDO_Controller.pInfor.NGAY_SUA = Convert.ToDateTime(Entity.Tables["HDG_VITRI_DDO"].Rows[0]["NGAY_SUA"].ToString());
            }
            if (Entity.Tables["HDG_VITRI_DDO"].Rows[0]["NGUOI_SUA"].ToString().Trim() != string.Empty)
            {
                this.obj_HDG_VITRI_DDO_Controller.pInfor.NGUOI_SUA = Convert.ToString(Entity.Tables["HDG_VITRI_DDO"].Rows[0]["NGUOI_SUA"].ToString());
            }
        }

        #endregion

        #region Methos       

        public DataSet Get_THONGTIN_KHANG_sogcs(string strMa_dviqly, string strMa_sogcs, ref string strErr)
        {
            try
            {
                DataSet ds = new DataSet();
                ds = obj_THONGTIN_KHANG_Controller.Get_THONGTIN_KHANG_sogcs(strMa_dviqly, strMa_sogcs, ref strErr);
                return ds;
            }
            catch
            {
                return null;
            }
        }

        public DataSet Get_THONGTIN_KHANG_sogcs_SMS(string strMa_dviqly, string strMa_sogcs, ref string strErr)
        {
            try
            {
                DataSet ds = new DataSet();
                ds = obj_THONGTIN_KHANG_Controller.Get_THONGTIN_KHANG_sogcs_SMS(strMa_dviqly, strMa_sogcs, ref strErr);
                return ds;
            }
            catch
            {
                return null;
            }
        }

        public DataSet Get_THONGTIN_KHANG_tram(string strMa_dviqly, string strMa_tram, ref string strErr)
        {
            try
            {
                DataSet ds = new DataSet();
                ds = obj_THONGTIN_KHANG_Controller.Get_THONGTIN_KHANG_tram(strMa_dviqly, strMa_tram, ref strErr);
                return ds;
            }
            catch
            {
                return null;
            }
        }
        
        public bool insert_HDG_KHACH_HANG(DataSet Entity, ref string maloi)
        {
            this.mapEntityToInfoHDG_KHACH_HANG(Entity);
            if (obj_HDG_KHACH_HANG_Controller == null)
            {
                obj_HDG_KHACH_HANG_Controller = new cls_HDG_KHACH_HANG_Controller();
            }
            return this.obj_HDG_KHACH_HANG_Controller.insert_HDG_KHACH_HANG(ref maloi);
        }
        public bool insert_HDG_DIEM_DO(DataSet Entity, ref string maloi)
        {
            this.mapEntityToInfoHDG_DIEM_DO(Entity);
            if (obj_HDG_DIEM_DO_Controller == null)
            {
                obj_HDG_DIEM_DO_Controller = new cls_HDG_DIEM_DO_Controller();
            }
            return this.obj_HDG_DIEM_DO_Controller.insert_HDG_DIEM_DO(ref maloi);
        }
        public bool insert_HDG_VITRI_DDO(DataSet Entity, ref Int64 id_vitri_ddo, ref string maloi)
        {
            this.mapEntityToInfoHDG_VITRI_DDO(Entity);
            if (obj_HDG_VITRI_DDO_Controller == null)
            {
                obj_HDG_VITRI_DDO_Controller = new cls_HDG_VITRI_DDO_Controller();
            }
            return this.obj_HDG_VITRI_DDO_Controller.insert_HDG_VITRI_DDO(ref id_vitri_ddo, ref maloi);
        }

        public bool update_HDG_KHACH_HANG(DataSet Entity, ref string strErr)
        {
            this.mapEntityToInfoHDG_KHACH_HANG(Entity);
            if (obj_HDG_KHACH_HANG_Controller == null)
            {
                obj_HDG_KHACH_HANG_Controller = new cls_HDG_KHACH_HANG_Controller();
            }
            return this.obj_HDG_KHACH_HANG_Controller.update_HDG_KHACH_HANG(ref strErr);
        }

        public bool delete_HDG_KHACH_HANG(DataSet ds, ref string maloi)
        {
            if (obj_HDG_KHACH_HANG_Controller == null)
            {
                obj_HDG_KHACH_HANG_Controller = new cls_HDG_KHACH_HANG_Controller();
            }
            return this.obj_HDG_KHACH_HANG_Controller.delete_HDG_KHACH_HANG(ds.Tables["HDG_KHACH_HANG"], ref maloi);
        }
        public bool delete_HDG_DIEM_DO(DataSet ds, ref string maloi)
        {
            if (obj_HDG_DIEM_DO_Controller == null)
            {
                obj_HDG_DIEM_DO_Controller = new cls_HDG_DIEM_DO_Controller();
            }
            return this.obj_HDG_DIEM_DO_Controller.delete_HDG_DIEM_DO(ds.Tables["HDG_DIEM_DO"], ref maloi);
        }
        public bool delete_HDG_VITRI_DDO(DataSet ds, ref string maloi)
        {
            if (obj_HDG_VITRI_DDO_Controller == null)
            {
                obj_HDG_VITRI_DDO_Controller = new cls_HDG_VITRI_DDO_Controller();
            }
            return this.obj_HDG_VITRI_DDO_Controller.delete_HDG_VITRI_DDO(ds.Tables["HDG_VITRI_DDO"], ref maloi);
        }        

        #endregion
    }
}
